package com.qf.utils;

import com.alibaba.druid.pool.DruidDataSource;
import org.apache.commons.dbutils.QueryRunner;

import javax.sql.DataSource;

/**
 * Create by 周志豪 on 2022/8/15  10:45
 *
 * @authoe 周志豪
 * @veision 1.0
 * //TODO  想好了再去做
 * @since 1.0
 */

public class DbUtils {

    private static DataSource dataSource;

    static {
        dataSource = new DruidDataSource();
        ((DruidDataSource) dataSource).setUsername("root");
        ((DruidDataSource) dataSource).setPassword("123456");
        ((DruidDataSource) dataSource).setUrl("jdbc:mysql:///db_shopping?useUnicode=true&characterEncoding=utf8&useSSL=false");
        ((DruidDataSource) dataSource).setDriverClassName("com.mysql.jdbc.Driver");
        ((DruidDataSource) dataSource).setMaxWait(5000);
        ((DruidDataSource) dataSource).setMinIdle(5);
    }

    public static QueryRunner getRunner() {
        return new QueryRunner(dataSource);
    }
}
